home *** CD-ROM | disk | FTP | other *** search
/ Express Pd: GALORE / Express Pd Galore - The Amiga PD & Shareware CD (1994)(Express Pd)[!][Amiga-CD32-CDTV].iso / productivity / term / termmisc.asm < prev    next >
Assembly Source File  |  1993-07-16  |  3KB  |  151 lines

  1. **
  2. **    termMisc.asm
  3. **
  4. **    Miscellaneous assembly language routines.
  5. **
  6. **    Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
  7. **        All Rights Reserved
  8. **
  9.  
  10.     include    "exec/types.i"
  11.     include    "exec/tasks.i"
  12.     include    "exec/execbase.i"
  13.  
  14. *--------------------------------------------------------------------------
  15.  
  16. CALL    macro
  17.     xref    _LVO\1
  18.     jsr    _LVO\1(a6)
  19.     endm
  20.  
  21. *--------------------------------------------------------------------------
  22.  
  23.     csect    text,0,0,1,2
  24.  
  25. *--------------------------------------------------------------------------
  26.  
  27.     xdef    _SPrintf
  28.     xdef    _VSPrintf
  29.  
  30.     xdef    _Atol
  31.     xdef    _StackReport
  32.  
  33. *--------------------------------------------------------------------------
  34.  
  35. _SPrintf:
  36.  
  37.     movem.l    a2/a3/a6,-(sp)        ; Save registers
  38.  
  39.     move.l     4+12(sp),a3        ; Get destination buffer
  40.     move.l     8+12(sp),a0        ; Get format string
  41.     lea    12+12(sp),a1        ; Get arguments
  42.     lea    stuffchar(pc),a2    ; Get formatting routine
  43.  
  44.     move.l    _SysBase(a4),a6        ; Get ExecBase
  45.     CALL    RawDoFmt        ; Format the string
  46.  
  47.     movem.l    (sp)+,a2/a3/a6        ; Restore registers
  48.  
  49.     rts
  50.  
  51. *--------------------------------------------------------------------------
  52.  
  53. _VSPrintf:
  54.  
  55.     movem.l    a2/a3/a6,-(sp)
  56.  
  57.     move.l     4+12(sp),a3
  58.     move.l     8+12(sp),a0
  59.     move.l    12+12(sp),a1
  60.     lea    stuffchar(pc),a2
  61.  
  62.     move.l    _SysBase(a4),a6
  63.     CALL    RawDoFmt
  64.  
  65.     movem.l    (sp)+,a2/a3/a6
  66.  
  67.     rts
  68.  
  69. stuffchar:
  70.  
  71.     move.b    d0,(a3)+
  72.     rts
  73.  
  74. *--------------------------------------------------------------------------
  75. *
  76. *    A tiny replacement for Atol(), implemented through StrToLong.
  77. *
  78. *--------------------------------------------------------------------------
  79.  
  80. _Atol:    move.l    a0,d1        ; Save argument
  81.  
  82.     movem.l    d2/a6,-(sp)    ; Save registers
  83.  
  84.     pea.l    0        ; Push a zero on the stack
  85.  
  86.     lea.l    (sp),a0        ; Get a pointer to the value
  87.     move.l    a0,d2        ; Get it into a convenient register
  88.  
  89.     move.l    _DOSBase(a4),a6    ; Get DOSBase
  90.  
  91.     CALL    StrToLong    ; Convert the string
  92.     tst.l    d0
  93.  
  94.     bgt.b    1$        ; Did we get anything sensible?
  95.  
  96.     addq    #4,sp        ; Fix the stack
  97.     moveq    #0,d0        ; Clear the result
  98.  
  99.     movem.l    (sp)+,d2/a6    ; Restore registers
  100.     rts
  101.  
  102. 1$    move.l    (sp)+,d0    ; Get the conversion result
  103.  
  104.     movem.l    (sp)+,d2/a6    ; Restore registers
  105.     rts
  106.  
  107. *--------------------------------------------------------------------------
  108. *
  109. *    A routine to return the amount of stack space currently
  110. *    in use. Quite useful for debugging purposes.
  111. *
  112. *--------------------------------------------------------------------------
  113.  
  114. _StackReport:
  115.  
  116.     move.l    a6,-(sp)        ; Save library base
  117.  
  118.     move.l    _SysBase(a4),a6        ; Get SysBase
  119.     move.l    ThisTask(a6),a0        ; We want to check ourselves
  120.  
  121.     move.l    TC_SPUPPER(a0),d0    ; Get the stack upper limit
  122.     sub.l    sp,d0            ; Subtract the current stack pointer
  123.     subq    #8,d0            ; Don't forget the remaining junk
  124.  
  125.     move.l    (sp)+,a6        ; Restore library base
  126.     rts
  127.  
  128. *--------------------------------------------------------------------------
  129. *
  130. *    These two lines are actually to make SLINK believe that some kind
  131. *    of startup code will clear the Data/BSS segment before running the
  132. *    main program. Since this is no longer necessary with Kickstart 2.x
  133. *    these two lines will save quite some disk space.
  134. *
  135. *--------------------------------------------------------------------------
  136.  
  137.     lea    __BSSBAS,a0
  138.     move.l    #__BSSLEN,d0
  139.  
  140. *--------------------------------------------------------------------------
  141.  
  142.     csect    __MERGED
  143.  
  144.     xref    _DOSBase
  145.     xref    _SysBase
  146.  
  147.     xref    __BSSBAS
  148.     xref    __BSSLEN
  149.  
  150.     end
  151.